
import locales from './utils/locales.js'
import T from './utils/wxapp-i18n.js'
T.registerLocale(locales)
//T.setLocale('zh-Hans')
let lang = wx.getStorageSync('lang');
if(lang){
  T.setLocale(lang)
}else{
  T.setLocale('zh-Hans')
}
wx.T = T
// console.log(wx.T);
let navText = {}
if (T.locale == 'en') {
  navText = locales['en']
} else if (T.locale == 'zh-Hans') {
  navText = locales['zh-Hans']
}
//console.log(navText);
//app.js
App({
  data:{

  },
  onLaunch: function (options) {

    wx.login({
      success: function (res) {
        if (res.code) {
         //console.log(res)
        } else {
          console.log('登录失败！' + res.errMsg)
        }
      }
    });

  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    //初始化时判断是否有用户
    wx.getStorage({
      //获取数据的key
      key: 'walletKey',
      success: function (res) {
        //console.log(res)
        if (res.data) {
          wx.reLaunch({
            url: '../../pages/assetPage/assetPage',
            success: function (res) {
              console.log('跳转到news页面成功')// success
            },
            fail: function (res) {
              console.log('跳转到news页面失败' + JSON.stringify(res))  // fail
            },
            complete: function (res) {
              console.log('跳转到news页面完成' + JSON.stringify(res)) // complete
            }
          })
        }else{
          wx.reLaunch({
            url: '../../pages/leadIndex/leadIndex'
          })
          wx.clearStorage();
        }
      },/**
       * 失败会调用
       */
      fail: function (res) {
        console.log(res)
      }
    })
  },

  globalData: {
    userInfo: null
  }
})